#ifndef INCLUDED_ENGINE_ID_H
#define INCLUDED_ENGINE_ID_H

//====================================================================================================
// Filename:	ID.h
// Created by:	Josh Blidook
// Description: Class for a meta type ID
//====================================================================================================

// Code from Slant 6, Peter thinks it might not be that good...

//====================================================================================================
// Includes
//====================================================================================================

#include "MetaTypes.h"

//====================================================================================================
// Class Declarations
//====================================================================================================

class ID
{
public:
	ID();
	ID(Meta::Type _type, u8 _instance, u16 index);
	//~ID();

	Meta::Type GetType() const	  { return (Meta::Type) m.type; }
	u8 GetInstance() const		  {return m.instance; }
	u16 GetIndex() const		  {return m.index; }

	bool IsValid() const		  { return blob != U32_MAX; }
	void Invalidate()			  { blob = U32_MAX; }

	bool operator==(ID rhs) const { return blob == rhs.blob; }
	bool operator!=(ID rhs) const { return blob != rhs.blob; }
	bool operator<(ID rhs) const  { return blob < rhs.blob; }

private:
	union
	{
		struct
		{
			u8 type;
			u8 instance; // The instance of that type0
			u16 index;
		} m; // Put name here so it creates it first?

		u32 blob; // Easy to compare this all in one blob
	};
};

//----------------------------------------------------------------------------------------------------


//----------------------------------------------------------------------------------------------------

//====================================================================================================
// Constants
//====================================================================================================

//----------------------------------------------------------------------------------------------------


#endif // #ifndef INCLUDED_ENGINE_ID_H